package com.test.ssh.service.impl;

import java.io.Serializable;
import java.util.List;

import com.test.ssh.dao.GenericDao;
import com.test.ssh.service.GenericManager;

public class GenericManagerImpl<T, PK extends Serializable> implements GenericManager<T, PK>{

	private GenericDao<T, PK> genericDao;
	@Override
	public void delete(T entity) {
		genericDao.delete(entity);
	}

	@Override
	public List findByHql(String hql, Object... params) {
		return genericDao.findByHql(hql, params);
	}

	@Override
	public T get(PK id) {
		return genericDao.get(id);
	}

	@Override
	public void remove(PK id) {
		T entity = get(id);
		genericDao.delete(entity);
	}

	@Override
	public T save(T entity) {
		return genericDao.save(entity);
	}

	public GenericDao<T, PK> getGenericDao() {
		return genericDao;
	}

	public void setGenericDao(GenericDao<T, PK> genericDao) {
		this.genericDao = genericDao;
	}
	public T findUniqueBy(Class persistentClass,String propertyName, Object value){
		return (T) this.genericDao.findUniqueBy(persistentClass, propertyName, value);
	}
}
